<?php
	function check($x)
	{
		if($x == 1)
		{
			return '<i class="icon-ok"></a>';
		}else{
			return NULL;
		}
	}

?>
<!--[if gte IE 9]>-->
<style>
table.table thead{
	display:block;
	position:relative;
	padding:10px;
}
table.table tbody{
	padding:10px;
	display:block;
	height:600px;
	overflow-y:scroll;
}

table.table tr td:nth-child(1),table.table tr  th:nth-child(1) { width: 190px; }
table.table tr td:nth-child(2),table.table tr  th:nth-child(2) { width: 100px; }
table.table tr td:nth-child(3),table.table tr  th:nth-child(3) { width: 100px; padding:0; }
table.table tr td:nth-child(4),table.table tr  th:nth-child(4) { width: 100px; padding:0;}
table.table tr td:nth-child(5),table.table tr  th:nth-child(5) { width: 100px; padding:0;}
table.table tr td:nth-child(6),table.table tr  th:nth-child(6) { width: 100px; padding:0;}
table.table tr td:nth-child(7),table.table tr  th:nth-child(7) { width: 100px; padding:0;}
table.table tr td:nth-child(8),table.table tr  th:nth-child(8) { width: 100px; padding:0;}
table.table tr td:nth-child(9),table.table tr  th:nth-child(9) { width: 100px; padding:0;}
</style>
<!--<![endif]-->

<fieldset>
<?=$system_message;?>
	<legend>Search Date</legend>
	<form action="<?=site_url('employee/intervals');?>" method="POST">
		<div class="well">
			<div class="input-prepend">
			  <span class="add-on">From:</span>
			  <input class="datepicker" id="prependedInput" value="<?=set_value('date_from');?>" name="date_from" type="text" placeholder="format mm/dd/yyyy" required>
			</div>
			<div class="input-prepend">
			  <span class="add-on">To</span>
			  <input class="datepicker" id="prependedInput" value="<?=set_value('date_to');?>" name="date_to" type="text" placeholder="format mm/dd/yyyy" required>
			</div>
			<input type="submit" name="check_date_intervals" value="Go" class="btn btn-primary btn-mini">
		</div>
	</form>
</fieldset>
<?if(!empty($time_sched_intervals)):?>
<fieldset>
	<legend>Daily Time Record (IN/OUT)</legend>
	<table class="table table-bordered table-striped"> 
	<thead id="head">
		<tr>
			<th>Employee Name</th>
			<th colspan="2" style="text-align:center;">AM</th>
			<th colspan="2" style="text-align:center;">PM</th>
			<th colspan="2" style="text-align:center;">&nbsp;</th>
			<th colspan="2" style="text-align:center;">Overtime</th>
			
		</tr>
		<tr>
			<th>&nbsp;</th>
			<th style="text-align:center;">In</th>
			<th style="text-align:center;">Out</th>
			<th style="text-align:center;">In</th>
			<th style="text-align:center;">Out</th>
			<th>Absent</th>
			<th>On-Leave</th>
			<th>Rest Day</th>
			<th>Holiday</th>
		</tr>
	</thead>
	<tbody>
		<?foreach($time_sched_intervals as $s):?>
			<?php
				$data[] = $s->date;
				end($data);
			
				if(prev($data) !== $s->date):
			?>
			<tr class="info">
				<td colspan="9" style="text-align:center;"><h2><?=date('l - F d, Y',strtotime($s->date));?></h2></td>
			</tr>
			<?endif;?>
			
			<tr>
				<td><?=strtoupper($s->lastname).' '.ucwords($s->firstname.' '.$s->middlename[0].'.');?></td>
				<td><?=$s->am_in?></td>
				<td><?=$s->am_out?></td>
				<td><?=$s->pm_in?></td>
				<td><?=$s->pm_out?></td>
				<td style="text-align:center;"><?=check($s->absent);?></td>
				<td style="text-align:center;"><?=check($s->leave);?></td>
				<td style="text-align:center;"><?=check($s->ot_restday);?></td>
				<td style="text-align:center;"><?=check($s->ot_holiday);?></td>
			</tr>
		<?endforeach;?>
			<tr class="warning">
				<td colspan="9" style="text-align:center;"><h2>~ END ~</h2></td>
			</tr>
	</tbody>
	</table>
	
<?else:?>
	<div class="alert alert-notice">
		No Attendance Found!.
	</div>

<fieldset>
<?endif;?>